/*
Copyright (c) 2008, Daniel Guerrero Martínez
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
	-Redistributions of source code must retain the above copyright notice, this
	list of conditions and the following disclaimer.
	-Redistributions in binary form must reproduce the above copyright notice,
	this list of conditions and the following disclaimer in the documentation
	and/or other materials provided with the distribution.
	-Neither the name of the <ORGANIZATION> nor the names of its contributors may
	be used to endorse or promote products derived from this software without
	specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
 */

package Imagenes;

import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Stroke;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import javax.swing.JColorChooser;

public class BarraHerramientas extends javax.swing.JInternalFrame {


    public BarraHerramientas() {
        initComponents();
        pincel = Figura.TIPO_LINEA;
        muestra1 = new Muestra();
        P_stroke.add(muestra1);
        muestra1.setLocation(4, 18);
        refrescar_muestra();
        P_color1.setVisible(false);
        color = Color.BLACK;
        color1 = Color.WHITE;
        AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1F);
        muestra_color.setBackground(color);
        muestra_color_gradiente.setBackground(color1);
        update_paint();
    }

 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupopincel = new javax.swing.ButtonGroup();
        grupogradiente = new javax.swing.ButtonGroup();
        separador = new javax.swing.JSeparator();
        separador2 = new javax.swing.JSeparator();
        P_pinceles = new javax.swing.JPanel();
        B_trazo = new javax.swing.JToggleButton();
        B_linea = new javax.swing.JToggleButton();
        B_rectangulo = new javax.swing.JToggleButton();
        B_circulo = new javax.swing.JToggleButton();
        B_mover = new javax.swing.JToggleButton();
        B_curva = new javax.swing.JToggleButton();
        B_curva_2c = new javax.swing.JToggleButton();
        B_texto = new javax.swing.JToggleButton();
        B_relleno = new javax.swing.JCheckBox();
        P_stroke = new javax.swing.JPanel();
        E_continuidad = new javax.swing.JLabel();
        B_continuidad = new javax.swing.JSlider();
        grosor = new javax.swing.JSpinner();
        E_muestra = new javax.swing.JLabel();
        E_grosor = new javax.swing.JLabel();
        B_fin_linea = new javax.swing.JComboBox();
        E_fin_de_linea = new javax.swing.JLabel();
        B_union_lineas = new javax.swing.JComboBox();
        E_union_lineas = new javax.swing.JLabel();
        P_color1 = new javax.swing.JPanel();
        muestra_color_gradiente = new javax.swing.JPanel();
        E_color = new javax.swing.JLabel();
        B_horizontal = new javax.swing.JRadioButton();
        B_vertical = new javax.swing.JRadioButton();
        P_elecion_paint = new javax.swing.JPanel();
        B_gradiente = new javax.swing.JCheckBox();
        P_color = new javax.swing.JPanel();
        muestra_color = new javax.swing.JPanel();
        E_color1 = new javax.swing.JLabel();
        B_transparencia = new javax.swing.JSlider();
        E_transparencia = new javax.swing.JLabel();

        FormListener formListener = new FormListener();

        setPreferredSize(new java.awt.Dimension(150, 600));
        setVisible(true);
        getContentPane().setLayout(null);
        getContentPane().add(separador);
        separador.setBounds(0, 358, 140, 10);
        getContentPane().add(separador2);
        separador2.setBounds(0, 110, 140, 6);

        grupopincel.add(B_trazo);
        B_trazo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/tazo.png"))); // NOI18N
        B_trazo.setPreferredSize(new java.awt.Dimension(30, 30));
        B_trazo.addActionListener(formListener);
        P_pinceles.add(B_trazo);

        grupopincel.add(B_linea);
        B_linea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/linea.PNG"))); // NOI18N
        B_linea.setSelected(true);
        B_linea.setPreferredSize(new java.awt.Dimension(30, 30));
        B_linea.addActionListener(formListener);
        P_pinceles.add(B_linea);

        grupopincel.add(B_rectangulo);
        B_rectangulo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/circulo.png"))); // NOI18N
        B_rectangulo.setPreferredSize(new java.awt.Dimension(30, 30));
        B_rectangulo.addActionListener(formListener);
        P_pinceles.add(B_rectangulo);

        grupopincel.add(B_circulo);
        B_circulo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/rectangulo.png"))); // NOI18N
        B_circulo.setPreferredSize(new java.awt.Dimension(30, 30));
        B_circulo.addActionListener(formListener);
        P_pinceles.add(B_circulo);

        grupopincel.add(B_mover);
        B_mover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/mover.png"))); // NOI18N
        B_mover.setPreferredSize(new java.awt.Dimension(30, 30));
        B_mover.addActionListener(formListener);
        P_pinceles.add(B_mover);

        grupopincel.add(B_curva);
        B_curva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/curva.png"))); // NOI18N
        B_curva.setPreferredSize(new java.awt.Dimension(30, 30));
        B_curva.addActionListener(formListener);
        P_pinceles.add(B_curva);

        grupopincel.add(B_curva_2c);
        B_curva_2c.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/curva2D.png"))); // NOI18N
        B_curva_2c.setPreferredSize(new java.awt.Dimension(30, 30));
        B_curva_2c.addActionListener(formListener);
        P_pinceles.add(B_curva_2c);

        grupopincel.add(B_texto);
        B_texto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/letras.png"))); // NOI18N
        B_texto.setText("A");
        B_texto.setPreferredSize(new java.awt.Dimension(30, 30));
        B_texto.addActionListener(formListener);
        P_pinceles.add(B_texto);

        B_relleno.setText("Relleno");
        P_pinceles.add(B_relleno);

        getContentPane().add(P_pinceles);
        P_pinceles.setBounds(0, 0, 140, 110);

        P_stroke.setLayout(null);

        E_continuidad.setText("Discontinuidad");
        P_stroke.add(E_continuidad);
        E_continuidad.setBounds(10, 200, 120, 13);

        B_continuidad.setMaximum(20);
        B_continuidad.setPaintLabels(true);
        B_continuidad.setPaintTicks(true);
        B_continuidad.setSnapToTicks(true);
        B_continuidad.setToolTipText("discontinuidad");
        B_continuidad.setValue(0);
        B_continuidad.addChangeListener(formListener);
        P_stroke.add(B_continuidad);
        B_continuidad.setBounds(10, 220, 120, 30);

        grosor.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(1.0f), Float.valueOf(10.0f), Float.valueOf(1.0f)));
        grosor.addChangeListener(formListener);
        P_stroke.add(grosor);
        grosor.setBounds(90, 60, 50, 20);

        E_muestra.setText("Muestra");
        P_stroke.add(E_muestra);
        E_muestra.setBounds(5, 0, 130, 20);

        E_grosor.setText("Grosor de linea");
        P_stroke.add(E_grosor);
        E_grosor.setBounds(0, 60, 90, 20);

        B_fin_linea.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "normal", "redondeado", "cuadrado" }));
        B_fin_linea.addItemListener(formListener);
        P_stroke.add(B_fin_linea);
        B_fin_linea.setBounds(10, 120, 120, 23);

        E_fin_de_linea.setText("Estilo de fin de linea");
        P_stroke.add(E_fin_de_linea);
        E_fin_de_linea.setBounds(10, 100, 120, 13);

        B_union_lineas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "cortado", "en pico", "redondeado" }));
        B_union_lineas.addItemListener(formListener);
        P_stroke.add(B_union_lineas);
        B_union_lineas.setBounds(10, 170, 120, 23);

        E_union_lineas.setText("Estilo de fin de linea");
        P_stroke.add(E_union_lineas);
        E_union_lineas.setBounds(10, 150, 120, 13);

        getContentPane().add(P_stroke);
        P_stroke.setBounds(0, 110, 140, 250);

        P_color1.setOpaque(false);
        P_color1.setLayout(null);

        muestra_color_gradiente.setBackground(new java.awt.Color(0, 0, 255));
        muestra_color_gradiente.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        muestra_color_gradiente.addMouseListener(formListener);

        javax.swing.GroupLayout muestra_color_gradienteLayout = new javax.swing.GroupLayout(muestra_color_gradiente);
        muestra_color_gradiente.setLayout(muestra_color_gradienteLayout);
        muestra_color_gradienteLayout.setHorizontalGroup(
            muestra_color_gradienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 26, Short.MAX_VALUE)
        );
        muestra_color_gradienteLayout.setVerticalGroup(
            muestra_color_gradienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 26, Short.MAX_VALUE)
        );

        P_color1.add(muestra_color_gradiente);
        muestra_color_gradiente.setBounds(100, 10, 30, 30);

        E_color.setText("Color2");
        P_color1.add(E_color);
        E_color.setBounds(70, 20, 40, 13);

        grupogradiente.add(B_horizontal);
        B_horizontal.setSelected(true);
        B_horizontal.setText("Horizontal");
        B_horizontal.addItemListener(formListener);
        P_color1.add(B_horizontal);
        B_horizontal.setBounds(0, 50, 120, 22);

        grupogradiente.add(B_vertical);
        B_vertical.setText("Vertical");
        P_color1.add(B_vertical);
        B_vertical.setBounds(0, 70, 60, 22);

        getContentPane().add(P_color1);
        P_color1.setBounds(0, 380, 140, 100);

        B_gradiente.setText("Gradiente");
        B_gradiente.addItemListener(formListener);

        javax.swing.GroupLayout P_elecion_paintLayout = new javax.swing.GroupLayout(P_elecion_paint);
        P_elecion_paint.setLayout(P_elecion_paintLayout);
        P_elecion_paintLayout.setHorizontalGroup(
            P_elecion_paintLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(P_elecion_paintLayout.createSequentialGroup()
                .addComponent(B_gradiente, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                .addContainerGap())
        );
        P_elecion_paintLayout.setVerticalGroup(
            P_elecion_paintLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(P_elecion_paintLayout.createSequentialGroup()
                .addComponent(B_gradiente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        getContentPane().add(P_elecion_paint);
        P_elecion_paint.setBounds(0, 360, 140, 20);

        P_color.setLayout(null);

        muestra_color.setBackground(new java.awt.Color(0, 0, 255));
        muestra_color.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        muestra_color.addMouseListener(formListener);

        javax.swing.GroupLayout muestra_colorLayout = new javax.swing.GroupLayout(muestra_color);
        muestra_color.setLayout(muestra_colorLayout);
        muestra_colorLayout.setHorizontalGroup(
            muestra_colorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 26, Short.MAX_VALUE)
        );
        muestra_colorLayout.setVerticalGroup(
            muestra_colorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 26, Short.MAX_VALUE)
        );

        P_color.add(muestra_color);
        muestra_color.setBounds(30, 10, 30, 30);

        E_color1.setText("Color");
        P_color.add(E_color1);
        E_color1.setBounds(0, 20, 34, 13);

        getContentPane().add(P_color);
        P_color.setBounds(0, 380, 60, 50);

        B_transparencia.setMaximum(10);
        B_transparencia.setValue(0);
        B_transparencia.addChangeListener(formListener);
        getContentPane().add(B_transparencia);
        B_transparencia.setBounds(0, 510, 140, 36);

        E_transparencia.setText("Transparencia");
        getContentPane().add(E_transparencia);
        E_transparencia.setBounds(0, 490, 130, 30);

        pack();
    }

    // Code for dispatching events from components to event handlers.

    private class FormListener implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.MouseListener, javax.swing.event.ChangeListener {
        FormListener() {}
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (evt.getSource() == B_trazo) {
                BarraHerramientas.this.B_trazo_pincel(evt);
            }
            else if (evt.getSource() == B_linea) {
                BarraHerramientas.this.B_lineaActionPerformed(evt);
            }
            else if (evt.getSource() == B_rectangulo) {
                BarraHerramientas.this.B_rectanguloActionPerformed(evt);
            }
            else if (evt.getSource() == B_circulo) {
                BarraHerramientas.this.B_circuloActionPerformed(evt);
            }
            else if (evt.getSource() == B_mover) {
                BarraHerramientas.this.B_moverActionPerformed(evt);
            }
            else if (evt.getSource() == B_curva) {
                BarraHerramientas.this.B_curva_pincel(evt);
            }
            else if (evt.getSource() == B_curva_2c) {
                BarraHerramientas.this.B_curva_2c_pincel(evt);
            }
            else if (evt.getSource() == B_texto) {
                BarraHerramientas.this.B_texto_pincel(evt);
            }
        }

        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            if (evt.getSource() == B_fin_linea) {
                BarraHerramientas.this.cambio_estilo_fin_de_linea(evt);
            }
            else if (evt.getSource() == B_union_lineas) {
                BarraHerramientas.this.cambio_union_linea(evt);
            }
            else if (evt.getSource() == B_horizontal) {
                BarraHerramientas.this.B_horizontalItemStateChanged(evt);
            }
            else if (evt.getSource() == B_gradiente) {
                BarraHerramientas.this.cambio_gradiente(evt);
            }
        }

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (evt.getSource() == muestra_color_gradiente) {
                BarraHerramientas.this.muestra_color_gradienteMouseClicked(evt);
            }
            else if (evt.getSource() == muestra_color) {
                BarraHerramientas.this.muestra_colorMouseClicked(evt);
            }
        }

        public void mouseEntered(java.awt.event.MouseEvent evt) {
        }

        public void mouseExited(java.awt.event.MouseEvent evt) {
        }

        public void mousePressed(java.awt.event.MouseEvent evt) {
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
        }

        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            if (evt.getSource() == B_continuidad) {
                BarraHerramientas.this.cambio_discontinuidad(evt);
            }
            else if (evt.getSource() == grosor) {
                BarraHerramientas.this.grosorStateChanged(evt);
            }
            else if (evt.getSource() == B_transparencia) {
                BarraHerramientas.this.B_transparenciaStateChanged(evt);
            }
        }
    }// </editor-fold>//GEN-END:initComponents

    private void B_lineaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_lineaActionPerformed
        pincel = Figura.TIPO_LINEA;
    }//GEN-LAST:event_B_lineaActionPerformed

    private void B_rectanguloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_rectanguloActionPerformed
        pincel = Figura.TIPO_CIRCULO;
    }//GEN-LAST:event_B_rectanguloActionPerformed

    private void B_circuloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_circuloActionPerformed
        pincel = Figura.TIPO_RECTANGULO;
    }//GEN-LAST:event_B_circuloActionPerformed

    private void B_moverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_moverActionPerformed
        pincel = Figura.TIPO_MOVER;
}//GEN-LAST:event_B_moverActionPerformed

    private void grosorStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_grosorStateChanged
        refrescar_muestra();
    }//GEN-LAST:event_grosorStateChanged

    private void cambio_estilo_fin_de_linea(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cambio_estilo_fin_de_linea
        switch(B_fin_linea.getSelectedIndex()){
            case 0:
                estilo_fin_linea = BasicStroke.CAP_BUTT;
                break;
            case 1:
                estilo_fin_linea = BasicStroke.CAP_ROUND;
                break;
            case 2:
                estilo_fin_linea = BasicStroke.CAP_SQUARE;
                break;
        }
        refrescar_muestra();
}//GEN-LAST:event_cambio_estilo_fin_de_linea

    private void cambio_union_linea(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cambio_union_linea
        switch(B_union_lineas.getSelectedIndex()){
            case 0:
                estilo_union = BasicStroke.JOIN_BEVEL;
                break;
            case 1:
                estilo_union = BasicStroke.JOIN_MITER;
                break;
            case 2:
                estilo_union = BasicStroke.JOIN_ROUND;
                break;
        }
        refrescar_muestra();
}//GEN-LAST:event_cambio_union_linea

    private void cambio_discontinuidad(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cambio_discontinuidad
        float nuevo = (float)(B_continuidad.getValue());
        if (nuevo <=10){
            dash[0]= 10;
            dash[1] = nuevo;
            dash[2] = 0;
            dash[3] = 0;
        }else{
            dash[0] = 10;
            dash[1] = 10;
            if(nuevo <15){
                dash[2] = nuevo-10;
                dash[3] = 10;
            }else{
                dash[1] = 10 - (nuevo-10);
                dash[2] = 5;
                dash[3] = 10 - (nuevo-10);
            }

        }
        refrescar_muestra();
    }//GEN-LAST:event_cambio_discontinuidad

    private void muestra_color_gradienteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_muestra_color_gradienteMouseClicked
        color1 = JColorChooser.showDialog(this, "seleccion color", color1);
        muestra_color_gradiente.setBackground(color1);
        update_paint();
}//GEN-LAST:event_muestra_color_gradienteMouseClicked

    private void muestra_colorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_muestra_colorMouseClicked
        color = JColorChooser.showDialog(this, "seleccion color", color);
        muestra_color.setBackground(color);
        update_paint();
}//GEN-LAST:event_muestra_colorMouseClicked

    private void cambio_gradiente(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cambio_gradiente
        if(B_gradiente.isSelected()){
            P_color1.setVisible(true);
        }else{
            P_color1.setVisible(false);
        }
        update_paint();
    }//GEN-LAST:event_cambio_gradiente

    private void B_horizontalItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_B_horizontalItemStateChanged
        update_paint();
    }//GEN-LAST:event_B_horizontalItemStateChanged

    private void B_curva_pincel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_curva_pincel
        pincel = Figura.TIPO_CURVA;
    }//GEN-LAST:event_B_curva_pincel

    private void B_curva_2c_pincel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_curva_2c_pincel
        pincel = Figura.TIPO_CURVA_2C;
}//GEN-LAST:event_B_curva_2c_pincel

    private void B_texto_pincel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_texto_pincel
        pincel = Figura.TIPO_TEXTO;
}//GEN-LAST:event_B_texto_pincel

    private void B_trazo_pincel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_trazo_pincel
        pincel = Figura.TIPO_TRAZO;
}//GEN-LAST:event_B_trazo_pincel

    private void B_transparenciaStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_B_transparenciaStateChanged
        this.refrescar_muestra();
    }//GEN-LAST:event_B_transparenciaStateChanged

    public void update_paint(){
        if(!B_gradiente.isSelected()){
            paint = color;
        }else{
            if(B_horizontal.isSelected()){
                paint = new java.awt.GradientPaint(new Point2D.Double(0, Alto/2), color, new Point2D.Double(Ancho, Alto/2), color1);
            }else{
                paint = new java.awt.GradientPaint(new Point2D.Double(Ancho/2, 0), color, new Point2D.Double(Ancho/2, Alto), color1);
            }
        }
    }

    public void mod_point_gradiente(int ancho,int alto){
        Alto = alto;
        Ancho = ancho;
    }

    private void refrescar_muestra(){
        stroke = new BasicStroke(((Float)grosor.getValue()),estilo_fin_linea,estilo_union,10,dash,0F);
        alfa = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1F - B_transparencia.getValue()*0.1F);
        muestra1.setstroke(stroke);
        muestra1.repaint();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton B_circulo;
    private javax.swing.JSlider B_continuidad;
    private javax.swing.JToggleButton B_curva;
    private javax.swing.JToggleButton B_curva_2c;
    private javax.swing.JComboBox B_fin_linea;
    private javax.swing.JCheckBox B_gradiente;
    private javax.swing.JRadioButton B_horizontal;
    private javax.swing.JToggleButton B_linea;
    private javax.swing.JToggleButton B_mover;
    private javax.swing.JToggleButton B_rectangulo;
    protected javax.swing.JCheckBox B_relleno;
    private javax.swing.JToggleButton B_texto;
    private javax.swing.JSlider B_transparencia;
    private javax.swing.JToggleButton B_trazo;
    private javax.swing.JComboBox B_union_lineas;
    private javax.swing.JRadioButton B_vertical;
    private javax.swing.JLabel E_color;
    private javax.swing.JLabel E_color1;
    private javax.swing.JLabel E_continuidad;
    private javax.swing.JLabel E_fin_de_linea;
    private javax.swing.JLabel E_grosor;
    private javax.swing.JLabel E_muestra;
    private javax.swing.JLabel E_transparencia;
    private javax.swing.JLabel E_union_lineas;
    private javax.swing.JPanel P_color;
    private javax.swing.JPanel P_color1;
    private javax.swing.JPanel P_elecion_paint;
    private javax.swing.JPanel P_pinceles;
    private javax.swing.JPanel P_stroke;
    private javax.swing.JSpinner grosor;
    private javax.swing.ButtonGroup grupogradiente;
    private javax.swing.ButtonGroup grupopincel;
    private javax.swing.JPanel muestra_color;
    private javax.swing.JPanel muestra_color_gradiente;
    private javax.swing.JSeparator separador;
    private javax.swing.JSeparator separador2;
    // End of variables declaration//GEN-END:variables
    private Color color,color1;
    private Muestra muestra1;
    protected int pincel;
    protected Stroke stroke;
    protected Paint paint;
    protected AlphaComposite alfa;
    private Float num_grosor = 1F;
    private int estilo_union = java.awt.BasicStroke.JOIN_BEVEL;
    private int estilo_fin_linea = java.awt.BasicStroke.CAP_BUTT;
    private float dash[]= {10.0F,0.0F,0F,0F};
    private int Alto;
    private int Ancho;


    private class Muestra extends javax.swing.JPanel {
        Line2D linea;
        BarraHerramientas creador = null;
        Stroke stroke;
 
        public Muestra() {
            initComponents();
            this.setSize(130, 30);
            stroke = new java.awt.BasicStroke();
            linea = new Line2D.Double(10, (this.getHeight()/2), this.getWidth()-10, (this.getHeight()/2));
        }

        @Override
        public void paint(Graphics G){
            G.clearRect(0, 0, this.getWidth(), this.getHeight());
            this.paintBorder(G);
            Graphics2D g = ((Graphics2D) G);
            g.setStroke(stroke);
            g.draw(linea);
        }


        public void setstroke(Stroke S){
            stroke = S;
            this.repaint();
        }

        private void initComponents() {

            setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
            setLayout(null);
        }

    }

}
